package com.locationtracker.plus.viewmodel.request

import androidx.lifecycle.MutableLiveData
import com.blankj.utilcode.util.TimeUtils
import com.locationtracker.plus.BuildConfig
import com.locationtracker.plus.app.appViewModel
import com.locationtracker.plus.app.network.apiService
import com.locationtracker.plus.data.model.bean.RechargeResponse
import me.hgj.jetpackmvvm.base.viewmodel.BaseViewModel
import me.hgj.jetpackmvvm.ext.request
import me.hgj.jetpackmvvm.ext.requestNoCheck
import me.hgj.jetpackmvvm.state.ResultState

class RequestPayViewModel : BaseViewModel() {

    var productListData = MutableLiveData<ResultState<ArrayList<RechargeResponse>>>()

    fun productList() {
        request({ apiService.productList() }, productListData, true)
    }

    fun updateEvent(event: String) {
        requestNoCheck({
            apiService.eventUpdate(mutableMapOf<String, Any>().apply {
                this["sub_type"] = "LocationTrackerPlus"
                this["remark"] = "/"
                this["source"] = "android"
                this["uid"] = appViewModel.userInfo.value?.id ?: "/"
                this["version"] = BuildConfig.VERSION_NAME
                this["event_time"] = TimeUtils.getNowString()
                this["key"] = event
            })
        }, {}, isShowDialog = false)
    }
}